package util;

import java.math.BigInteger;
import java.security.MessageDigest;

/**
 * 加密工具
 * Created by cuihao on 2017/9/4.
 */
public class UtilEncrypt {

    /*    public static String encryptBase(byte[] key)throws  Exception{
            byte jj[] = (new BASE64Decoder).decodeBuffer();

        }*/
    public static final String KEY_MD = "MD5";
    public static final String KEY_SHA = "SHA";

    /**
     * MD
     *
     * @param inputStr
     * @return
     */
    public static String getResult(String inputStr) {
        System.out.println("before enctpt data " + inputStr);
        BigInteger bigInteger = null;
        try {
            MessageDigest messageDigest = MessageDigest.getInstance(KEY_MD);
            byte[] inputData = inputStr.getBytes();
            messageDigest.update(inputData);
            bigInteger = new BigInteger(messageDigest.digest());
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        System.out.print("after enctpt data " + bigInteger);
        return bigInteger.toString();

    }

}
